// components/mynav/mynav.js
const app=getApp()
Component({
  /**
   * 组件的属性列表
   */

  properties: {
    custom: {
      type: Boolean,
      default: false
    }, //自定义头部，否则沿用原生的头部样式


    navigationBarStyle: {
      type: Object,
      default: function () {
        return {
          background: '#1d1515',
          fontColor: '#f5efef',
          iconColor: '#f5efef',
          iconText: '好运牛' //导航栏文字
        }
      }
    }, //原生头部自定义样式

    showhome: {
      type: Boolean,
      default: true,
    }, //是否显示小房子
    showBack: {
      type: Boolean,
      default: false
    }, //是否显示回退图标，默认显示
    gray: {
      type: Boolean,
      default: false
    }, //北京是否要灰色
    title: {
      type: String,
      default: "顺辉包铺贴小程序"
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    normal: {
      background: '#FFFFFF',
      fontColor: '#000000',
      iconColor: '#000000',
    }, //公用样式,个性化样式可通过传值实现
    lineHeight: '' //状态栏高度
  },
  ready() {
    let menuButtonInfo = wx.getMenuButtonBoundingClientRect()
    // console.log("menuButtonInfo",menuButtonInfo)
    const systemInfo = wx.getSystemInfoSync();
    // px转换到rpx的比例
    let pxToRpxScale = 750 / systemInfo.windowWidth;
    let systems = {
      ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
      navigationHeight: 44 * pxToRpxScale, // 导航栏的高度
      ktxWindowWidth: systemInfo.windowWidth * pxToRpxScale, // window的宽度
      ktxWindowHeight: systemInfo.windowHeight * pxToRpxScale, // window的高度
      ktxScreentHeight: systemInfo.screenHeight * pxToRpxScale, // 屏幕的高度
    }
    // 底部tabBar的高度
    systems.tabBarHeight = systems.ktxScreentHeight - systems.ktxStatusHeight - systems.navigationHeight - systems.ktxWindowHeight // 底部tabBar的高度
    this.setData({
      lineHeight: systems.ktxStatusHeight 
    })
    let t=this
      var query = wx.createSelectorQuery().in(this);
      query.select('.sticky').boundingClientRect(function (rect) {
   if(rect){
    let rpx=app.globalData.width/750
    // console.log(rect.height/rpx)
    t.setData({
      maskheight:rect.height/rpx
    })
    app.globalData.maskheight=rect.height
  // console.log(t.data.maskheight)
   }
         
    }).exec();
    // this.lineHeight = systems.ktxStatusHeight + 'rpx';
    // console.log( this," this.$emit")
    // this.$emit('getHeight', systems)
    // console.log(this.data.lineHeight,"lineHeight")

  


  },
  /**
   * 组件的方法列表
   */
  methods: {

    gos() {
      getApp().globalData.tabindex = 0
      wx.switchTab({
        url: '/pages/index/index',
        success() {

        }
      })
    },
    hoback() {
      wx.navigateBack({
        delta: 1,
      })
    }
  }
})